home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Printer.h
-
- Contains: Printing utility for OpenDoc, with QuickDraw & GX support.
-
- Owned by: Jens Alfke (with help from Steve Smith & Thomas Weisbach)
-
- Copyright: © 1995-96 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 2/2/96 JA Filled in header comments
- <1> 2/2/96 JA first checked in
-
- To Do:
- */
-
-
- #ifndef _PRINTER_
- #define _PRINTER_
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
-
- //=================================================================================
- // Resource ID declarations:
- //
- // Used by the DisplayError method. Clients don't need to use these resource
- // IDs, but they need to be aware of them so they can provide the appropriate
- // resources (or renumber the IDs if they prefer to use different numbering.)
- //
- // Standard resources matching these descriptions are in Printer.r.
- //=================================================================================
-
- enum
- {
- rPrintErrorsID = 32000, // 'STR#' resource of printing error messages
-
- rMenuStrID = 32001, // 'STR#' resource of "Undo" / "Redo" strings
- kPMUndoStrIndex = 1, // Index of "Undo" string in rMenuStrID
- kPMRedoStrIndex, // Index of "Redo" string in rMenuStrID
-
- rPrintErrorDialog = 32000 // 'ALRT' of printing-error alert
- };
-
-
- //=================================================================================
- // CPrinter
- //=================================================================================
-
-
- struct Environment;
- class ODFacet;
- class ODFrame;
- class ODSession;
- class ODShape;
- class ODStorageUnit;
-
-
- class CPrinter {
-
- public:
-
- // -- Factory method & destructor --
- static CPrinter* New( Environment*, ODStorageUnit* );
-
- virtual ~CPrinter();
-
- // -- Storage --
- void Externalize( Environment*, ODStorageUnit* =kODNULL );
-
- // -- Getters --
- virtual ODGraphicsSystem GetGraphicsSystem( ) =0;
- ODPlatformPrintJob GetPlatformPrintJob( Environment* );
- virtual ODRect GetPageRect( Environment* ) =0;
-
- // -- Printing --
- ODBoolean PageSetup( Environment* );
- void PrintDocument( Environment*, ODFrame* initiator, ODShape* area =kODNULL );
-
- protected:
- // -- Private stuff --
- CPrinter();
-
- virtual void Initialize( Environment*, ODStorageUnit *su );
-
- virtual void OpenPrinting( );
- virtual void ClosePrinting( );
- inline ODBoolean IsPrintingOpen( ) {return fPrintingOpen;}
-
- virtual ODValueType GetValueType( ) =0;
- virtual ODValueType GetSecondaryValueType( ) {return kODNULL;}
- virtual ODPlatformPrintJob BasicGetPlatformPrintJob( ) =0;
- virtual ODPlatformPrintJob ReadJobFromHandle( ODValueType valueType, ODHandle) =0;
- virtual ODPlatformPrintJob CreateNewJob() =0;
- virtual ODHandle CopyJobToHandle( ) =0;
-
- virtual void SetupPrintingEnv( Environment*, ODFrame* initiator, ODShape *area );
- virtual void CleanupPrintingEnv( Environment*, ODFrame* initiator );
- virtual ODPlatformCanvas CreatePrintingPlatformCanvas( Environment*, ODGraphicsSystem,
- ODFrame *initiator, ODShape *area ) =0;
- virtual ODULong CountPages( Environment*, ODShape* area );
-
- virtual void PrintPage( Environment*, ODUShort page, ODShape *area );
- virtual void SetPage( Environment*, ODUShort pageNum, ODShape* area );
-
- virtual void OpenPage( Environment*, ODUShort page ) =0;
- virtual void ClosePage( Environment* ) =0;
-
- virtual ODBoolean RunPageSetupDialog( Environment *ev ) =0;
- virtual ODBoolean RunPrintDialog( Environment *ev ) =0;
- virtual void DoPrint( Environment*, ODShape* area ) =0;
-
- virtual void DisplayError( Environment*, ODSShort error );
-
- ODSession* fSession;
- ODStorageUnit* fSU;
- ODFacet* fPrintFacet;
- ODBoolean fDirty;
- ODSShort fPrintingOpen;
-
- friend class CWithPrintingOpen;
- };
-
-
- //=================================================================================
- // Private stuff
- //=================================================================================
-
- #ifdef _PRINTER_PRIVATE_
-
- #ifndef __PRINTING__
- #include <Printing.h> /* For THPrint and TPrPort */
- #endif
-
- #ifndef __GXPRINTING__
- #include <GXPrinting.h>
- #endif
-
- #ifndef __GXENVIRONMENT__
- #include <GXEnvironment.h>
- #endif
-
- class ODWindowState;
-
- //-----------------------------------------------
-
- class CQDPrinter : public CPrinter {
-
- public:
- CQDPrinter();
- virtual ~CQDPrinter();
-
- protected:
- virtual void OpenPrinting( );
- virtual void ClosePrinting( );
- virtual ODGraphicsSystem GetGraphicsSystem( ) {return kODQuickDraw;}
- virtual ODValueType GetValueType( ) {return kODTypeQuickDrawPageSetup;}
- virtual ODPlatformPrintJob BasicGetPlatformPrintJob( ) {return (ODPlatformPrintJob)fJob;}
- virtual ODPlatformPrintJob ReadJobFromHandle( ODValueType valueType, ODHandle );
- virtual ODPlatformPrintJob CreateNewJob();
- virtual ODHandle CopyJobToHandle( );
- virtual ODPlatformCanvas CreatePrintingPlatformCanvas( Environment*, ODGraphicsSystem,
- ODFrame *initiator, ODShape *area );
- virtual ODRect GetPageRect( Environment* );
- virtual void CleanupPrintingEnv( Environment*, ODFrame* initiator );
- virtual void OpenPage( Environment*, ODUShort page );
- virtual void ClosePage( Environment* );
- virtual ODBoolean RunPageSetupDialog( Environment *ev );
- virtual ODBoolean RunPrintDialog( Environment *ev );
- virtual void DoPrint( Environment*, ODShape* area );
-
- private:
- THPrint fJob;
- TPrPort* fPort;
- Ptr fIOBuffer;
- ODBoolean fPageOpen;
- };
-
- //-----------------------------------------------
-
- class CGXPrinter : public CPrinter {
-
- public:
- CGXPrinter();
- virtual ~CGXPrinter();
-
- protected:
- virtual void Initialize( Environment*, ODStorageUnit *su );
- virtual ODGraphicsSystem GetGraphicsSystem( ) {return kODQuickDrawGX;}
- virtual ODValueType GetValueType( ) {return kODTypeGXPageSetup;}
- virtual ODValueType GetSecondaryValueType( ) {return kODTypeQuickDrawPageSetup;}
- virtual ODPlatformPrintJob BasicGetPlatformPrintJob( ) {return (ODPlatformPrintJob)fJob;}
- virtual ODPlatformPrintJob ReadJobFromHandle( ODValueType valueType, ODHandle );
- virtual ODPlatformPrintJob CreateNewJob();
- virtual ODHandle CopyJobToHandle( );
- virtual ODPlatformCanvas CreatePrintingPlatformCanvas( Environment*, ODGraphicsSystem,
- ODFrame *initiator, ODShape *area );
- virtual ODRect GetPageRect( Environment* );
- virtual void CleanupPrintingEnv( Environment*, ODFrame* initiator );
- virtual void OpenPage( Environment*, ODUShort page );
- virtual void ClosePage( Environment* );
- virtual ODBoolean RunPageSetupDialog( Environment *ev );
- virtual ODBoolean RunPrintDialog( Environment *ev );
- virtual void DoPrint( Environment*, ODShape* area );
-
- void EnableMenus( Environment*, ODBoolean enable );
-
- static OSErr PrintAShape( gxShape currentShape, long refCon );
-
- private:
- gxJob fJob;
- gxViewPort fViewPort;
- GrafPtr fQDPort;
- gxEditMenuRecord fEditMenuRec;
- gxShapeSpoolUPP fPrintAShapeProcPtr;
- ODBoolean fJobStarted;
- ODBoolean fPageOpen;
- };
-
- class CWithPrintingOpen :Destructo
- {
- public:
- CWithPrintingOpen( CPrinter* );
- ~CWithPrintingOpen( );
- private:
- CPrinter *fPrinter;
- };
-
- class CWithDialogState :Destructo
- {
- public:
- CWithDialogState( Environment *ev, ODSession *session );
- ~CWithDialogState( );
- private:
- Environment *fEv;
- ODWindowState *fWindowState;
- GrafPtr fPort;
- };
-
- void BusyCursor( );
-
- #endif /*_PRINTER_PRIVATE_*/
-
- #endif /*_PRINTER_*/
-